package com.liyi.service;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.liyi.dao.DepDao;
import com.zero.basic.exception.SmsErrorConstant;
import com.zero.basic.exception.SmsRuntimeException;
import com.zero.basic.exception.SmsStatusCode;
import com.zero.mms.model.Dep;

@Service("depServiceLiyi")
@Transactional(rollbackFor = Exception.class)
public class DepService {
		
		@Inject
		private DepDao depDaoLiyi;
		
		/* 获取 所有部门 列表 */
		public List<Dep> getAllDeps() throws SmsRuntimeException {
			try {
				return depDaoLiyi.getAllDeps();
			} catch (Exception e) {
				throw new SmsRuntimeException(SmsStatusCode.SERVER_ERROR, SmsErrorConstant.WEB_APPLICATION, "服务器异常");
			}
		}
		
		/* 根据 [部门]id 获取 [部门]名称 */
		public String getDepNameByDepId(Integer depId) throws SmsRuntimeException {
			try {
				return depDaoLiyi.getDepNameByDepId(depId);
			} catch (Exception e) {
				throw new SmsRuntimeException(SmsStatusCode.SERVER_ERROR, SmsErrorConstant.WEB_APPLICATION, "服务器异常");
			}
		}
}